<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("warcorps", $con);
$dateTime = date("Y-m-d",strtotime("-1 day"));
#$dateTime = '2012-03-28';
$logdate =  mysql_query("SELECT DISTINCT date FROM `warcorps_query`");
while($everylogdate = mysql_fetch_array($logdate))
{
  mysql_query("INSERT INTO warcorps_query_temp
SELECT max(id),
  firstlogindata,
  firstlogin,
  isJailbreak,
  isIAPCrack,
  BuyAmmoMoney,
  Character01PlayTotalTime,
  Character02PlayTotalTime,
  Character03PlayTotalTime,
  Character04PlayTotalTime,
  CurrentCrystal,
  CurrentMoney,
  UnlockCharacter01,
  UnlockCharacter02,
  UnlockCharacter03,
  UnlockCharacter04,
  I_Item00,
  I_Item01,
  I_Item02,
  I_Item03,
  I_Item04,
  I_Item05,
  I_Item06,
  I_Item07,
  I_Item08,
  I_Item09,
  I_Item10,
  I_Item11,
  I_Item12,
  I_Item13,
  I_Item14,
  I_Item15,
  I_Item16,
  Level,
  UnlockArmor,
  UnlockWeapon,
  gameId,
  gameVersion,
  timeBegin,
  timeEnd,
  paly0_timeEnter,
  paly0_timeLeave,
  paly1_timeEnter,
  paly1_timeLeave,
  paly2_timeEnter,
  paly2_timeLeave,
  paly3_timeEnter,
  paly3_timeLeave,
  paly4_timeEnter,
  paly4_timeLeave,
  paly5_timeEnter,
  paly5_timeLeave,
  paly6_timeEnter,
  paly6_timeLeave,
  paly7_timeEnter,
  paly7_timeLeave,
  paly8_timeEnter,
  paly8_timeLeave,
  paly9_timeEnter,
  paly9_timeLeave,
  iap_productId_0,
  iap_count_0,
  iap_productId_1,
  iap_count_1,
  iap_productId_2,
  iap_count_2,
  iap_productId_3,
  iap_count_3,
  iap_productId_4,
  iap_count_4,
  iap_productId_5,
  iap_count_5,
  iap_productId_6,
  iap_count_6,
  iap_productId_7,
  iap_count_7,
  iap_productId_8,
  iap_count_8,
  iap_productId_9,
  iap_count_9,
  iap_productId_10,
  iap_count_10,
  iap_productId_11,
  iap_count_11,
  iap_productId_12,
  iap_count_12,
  iap_productId_13,
  iap_count_13,
  iap_productId_14,
  iap_count_14,
  iap_productId_15,
  iap_count_15,
  deviceid,
  gamename,
  createdate,
  date
FROM warcorps_query
WHERE date = '$everylogdate[date]'
GROUP BY deviceid");
}
#mysql_query("INSERT INTO dinocap2hd SELECT NULL,dayGetMoney, dayIap1BuyTimes,dayIap2BuyTimes,dayIap3BuyTimes,dayIap4BuyTimes,dayIap5BuyTimes,dayIap6BuyTimes,dayIapMoney,dayPlayTime,dayTotalTime,dayUI1TapCount,dayUI2TapCount,dayUI3TapCount,dayUI4TapCount,dayUI5TapCount,dayUI6TapCount,dayUI7TapCount,dayUI8TapCount,dayUI9TapCount,dayUsedMoney,firstlogindata,firstlogin,fromNotificationCount,isjailbreak,lastMission,lastMissionState,lastMissionType,lastTapUI,mission1End,mission1Exit,mission1Retry,mission1Select,mission2End,mission2Exit,mission2Retry,mission2Select,mission3End,mission3Exit,mission3Retry,mission3Select,mission4End,mission4Exit,mission4Retry,mission4Select,mission5End,mission5Exit,mission5Retry,mission5Select,mission6End,mission6Exit,mission6Retry,mission6Select,mission7End,mission7Exit,mission7Retry,mission7Select,mission8End,mission8Exit,mission8Retry,mission8Select,nowMoney,player1DayExp,player1Level,player1TotalExp,player1Weapon1Level,weapon1IsUpdate,player1Weapon2Level,weapon2IsUpdate,player1Weapon3Level,weapon3IsUpdate,player1Weapon4Level,weapon4IsUpdate,player1Weapon5Level,weapon5IsUpdate,player1Weapon6Level,weapon6IsUpdate,player1WeaponBulletCount,player1WeaponBulletMoney,player1WeaponUpdateCount,player1WeaponUpdateMoney,player2DayExp,player2Level,player2TotalExp,player2Weapon1Level,weapon1IsUpdate_2,player2Weapon2Level,weapon2IsUpdate_2,player2Weapon3Level,weapon3IsUpdate_2,player2Weapon4Level,weapon4IsUpdate_2,player2Weapon5Level,weapon5IsUpdate_2,player2Weapon6Level,weapon6IsUpdate_2,player2WeaponBulletCount,player2WeaponBulletMoney,player2WeaponUpdateCount, player2WeaponUpdateMoney , player3DayExp, player3Level, player3TotalExp, player3Weapon1Level,weapon1IsUpdate_3,player3Weapon2Level,weapon2IsUpdate_3,player3Weapon3Level,weapon3IsUpdate_3,player3Weapon4Level,weapon4IsUpdate_3,player3Weapon5Level,weapon5IsUpdate_3,player3Weapon6Level,weapon6IsUpdate_3,player3WeaponBulletCount,player3WeaponBulletMoney,player3WeaponUpdateCount,player3WeaponUpdateMoney,player4DayExp,player4Level,player4TotalExp,player4Weapon1Level,weapon1IsUpdate_4,player4Weapon2Level,weapon2IsUpdate_4,player4Weapon3Level,weapon3IsUpdate_4,player4Weapon4Level,weapon4IsUpdate_4,player4Weapon5Level,weapon5IsUpdate_4,player4Weapon6Level,weapon6IsUpdate_4,player4WeaponBulletCount,player4WeaponBulletMoney,player4WeaponUpdateCount,player4WeaponUpdateMoney,player5DayExp,player5Level,player5TotalExp,player5Weapon1Level,weapon1IsUpdate_5,player5Weapon2Level,weapon2IsUpdate_5,player5Weapon3Level,weapon3IsUpdate_5,player5Weapon4Level,weapon4IsUpdate_5,player5Weapon5Level,weapon5IsUpdate_5,player5Weapon6Level,weapon6IsUpdate_5,player5WeaponBulletCount,player5WeaponBulletMoney,player5WeaponUpdateCount,player5WeaponUpdateMoney,totalMoney,totalTime,deviceid,gamename,whatday,createdate,date  FROM  dinocap2hd_query_temp");
#mysql_query("rename table dinocap2hd_query_temp to dinocap2hd");
mysql_close($con);
?>